package servlet;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebListener;

@WebListener
public class ServletListener implements ServletContextListener, ServletRequestListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        ServletContext context = sce.getServletContext();
        System.out.println("servlet context init-" + context);
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        ServletContext context = sce.getServletContext();
        System.out.println("servlet context destroyed-" + context);
    }

    @Override
    public void requestInitialized(ServletRequestEvent sre) {
        ServletRequest request = sre.getServletRequest();
        System.out.println("servlet request init-" + request.getProtocol());
    }

    @Override
    public void requestDestroyed(ServletRequestEvent sre) {
        ServletRequest request = sre.getServletRequest();
        System.out.println("servlet request init destroyed-" + request.getProtocol());
    }
}